// pages/detail/detail.js
Page({

  data: {
    id: '',
    swipers: [],
    detail: {},
    flag: true,
    imgdetail: [],
    imgdeparameter: []
  },

  onLoad: function (options) {
    this.setData({
      id: options.id,
      swiper: []
    })
    this.getDetail()
    this.getImgdetail()
  },
  getDetail(){
    let that = this;
    wx.request({
      url: 'http://120.79.28.228:5000/detail?id='+that.data.id,
      success(res){
        console.log(res)
        let swipersDate = []
        swipersDate.push(res.data.image)
        swipersDate.push(res.data.image)
        swipersDate.push(res.data.image)
        that.setData({
            swiper: swipersDate,
            detail: res.data
        })
      }
    })
  },

  getImgdetail(){
    let that = this 
    wx.request({
      url: 'http://120.79.28.228:5000/img?id='+that.data.id,
      success(res){
        console.log(res)
        that.setData({
          imgdetail: res.data.imgdetail,
          imgdeparameter: res.data.imgdeparameter
        })
      }
    })
  },

  // 进入商品详情页
  imgdetailFlag(){
    this.setData({
      flag: true
    })
  },
  // 进入商品参数页
  imgdeparameterFlag(){
    this.setData({
      flag: false
    })
  }

})